package com.jewelry.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.jewelry.dao.IOrdersDAO;
import com.jewelry.service.IOrdersService;
import com.jewelry.service.ISeqService;
import com.jewelry.vo.OrdersVO;
import com.jewelry.vo.StatisticsVO;

public class OrdersServiceImpl implements IOrdersService {
	
	private IOrdersDAO ordersDAO;
	
	private ISeqService seqService;

	public ISeqService getSeqService() {
		return seqService;
	}

	public void setSeqService(ISeqService seqService) {
		this.seqService = seqService;
	}

	public IOrdersDAO getOrdersDAO() {
		return ordersDAO;
	}

	public void setOrdersDAO(IOrdersDAO ordersDAO) {
		this.ordersDAO = ordersDAO;
	}

	//===========================================================
	
	@Override
	public List<OrdersVO> getOrdersList(OrdersVO order) {
		return ordersDAO.getOrdersList(order);
	}

	@Override
	public List<StatisticsVO> getGroupByOrderState() {
		List<StatisticsVO> temp = new ArrayList<StatisticsVO>(5);
		StatisticsVO vo = null;
		for(int i=1;i<=5;i++){
			vo = new StatisticsVO();
			vo.setType(i);
			temp.add(vo);
		}
		List<StatisticsVO> list = ordersDAO.getGroupByOrderState();
		for(StatisticsVO svo:temp ){
			if(!list.contains(svo)){
				list.add(svo);
			}
		}
		return list;
	}

	@Override
	public List<OrdersVO> getOrdersListByPage(OrdersVO order) {
		int totalCount = ordersDAO.getOrdersCount(order);
		order.getPage().setTotalItem(totalCount);
		List<OrdersVO> list = ordersDAO.getOrdersListByPage(order);
		return list;
	}

	@Override
	public String getOrderID() {
		return seqService.getOrderID();
	}

}
